package org.jeecg.modules.wlhy.bill.controller;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.wlhy.bill.entity.HyCarrierBill;
import org.jeecg.modules.wlhy.bill.service.IHyCarrierBillService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/bill/hyPayFail")
@Slf4j
public class HyPayFailController extends JeecgController<HyCarrierBill, IHyCarrierBillService> {

    @Value(value="${jeecg.path.paylogpath}")
    public String logpath;

   @GetMapping(value = "/list")
   public Result<?> queryPageList(HttpServletRequest req) {
       List<Map> filelist = new ArrayList<>();
       File file = new File(logpath);
       File[] files = file.listFiles();
       if (files.length!=0&&files!=null){
           for (File file1 : files) {
               if(file1.isFile()){
                   Map map = new HashMap();
                   map.put("fileName",file1.getName());
                   filelist.add(map);
               }
           }

       }
       log.info("files==========="+files.length);
       return Result.OK(filelist);
   }

}
